package cloud.lysky.java.on.design_pattern.chain_of_responsibility;

import java.util.function.Function;
import java.util.function.UnaryOperator;

/**
 * @author luoly
 * @describe
 * @date 2022-08-20 11:49
 **/
public class LambdaApp {
    public static void main(String[] args) {
        //第一个处理器
        UnaryOperator<String> headerProcessing = text -> "From Raoul, Mario and Alan:" + text;
        //第二个处理器
        UnaryOperator<String> spellCheckerProcessing = text -> text.replaceAll("ugly","beautiful");
        //将两个方法结合起来，结果就是一个操作链
        Function<String,String> pipeline = headerProcessing.andThen(spellCheckerProcessing);
        String result = pipeline.apply("James is a ugly man!");
        System.out.println(result);
    }
}